$(document).ready(function () {
    let jis=$("#jis")
    let cartCount=1
    $("#zj").on("click",function () {
        $("#showadd").val(++cartCount)
    });
    jis.click(function () {
        $("#showadd").val(--cartCount)
    })
});
$(function () {
    let addCart = $('#add_cart');
    let addCartX = addCart.offset().top;
    let addCartY = addCart.offset().left;
    let showCountX = $('#show_count').offset().top;
    let showCountY = $('#show_count').offset().left;
    let cartCount = 0;
    $(".add_jump").css({'left': addCartY + 80, 'top': addCartX + 10, 'display': 'block'})
    addCart.click(function () {
        var name = $("h3").html();
        var username = $("[class=\"login_info fl\"]").val();
        var qu = $("#showadd").val();
        $.get("pc/trolley/add",
            {
                "quantity": qu,
                "fname": name,
                "nickname": username
            },
            function (b
            ) {
                if (b) {
                    $(".add_jump").stop().animate({
                            'left': showCountY + 7,
                            'top': showCountX + 7
                        },
                        "fast", function () {
                            $(".add_jump").fadeOut('fast', function () {
                                $('#show_count').html(++cartCount);
                                $(".add_jump").css({'left': addCartY + 80, 'top': addCartX + 10, 'display': 'block'})
                            });
                        });
                } else {
                    alert("添加购物车失败")
                }

            })
    })

});



